﻿@{
    ViewBag.Title = "客户级别";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}

<table id="dg" class="easyui-datagrid" style="width:100%; height: 750px;"
       url="/BasicManage/GetCustomerLevel" toolbar="#tb" title="客户级别" rownumbers="true"
       pagination="false" fitcolumns="true" singleselect="true">
    <thead>
        <tr>
            <th field="LevelName" align="right" width="15%">
                级别名称
            </th>
        </tr>
    </thead>
</table>
<div id="tb" style="padding: 3px; height: auto;">
    <div>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addCustomerLevel()">新建</a>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="editCustomerLevel()">编辑</a>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-no" plain="true" onclick="delCustomerLevel()">删除</a>
        <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="doSearch()">查询</a>
    </div>
</div>
<div id="dlg" class="easyui-dialog" title="新增" data-options="iconCls:'icon-save'"
     closed="true" style="width: 450px; height: 350px; padding: 10px 20px" buttons="#dlg-buttons" modal="true">
    <form id="fm" method="post" novalidate>
        <input type="hidden" name="Id" />
        <div class="fitem">
            <label>
                级别名称:
            </label>
            <input name="LevelName" class="easyui-textbox" data-options="required:true,validType:'length[1,50]',prompt:'1~50位汉字或字母'" style="width: 250px; height: 30px;" autocomplete="off" />
        </div>
    </form>
</div>
<div id="dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="saveCustomerLevel()">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
</div>


<script language="javascript" type="text/javascript">
    function doSearch() {
        $('#dg').datagrid('load', {
        });
    }
    function addCustomerLevel() {
        $('#fm').form('clear');
        $('#dlg').dialog('open');
        url = '/BasicManage/AddCustomerLevel';
    }

    function editCustomerLevel() {
        var row = $('#dg').datagrid('getSelected');
        if (!row) {
            Helper.Show('请选择需要编辑的信息?');
            return;
        }
        $('#dlg').dialog('open').dialog('setTitle', '编辑');
        $('#fm').form('load', row);
        $.messager.progress('close');

        url = "/BasicManage/EditCustomerLevel";
    }

    function delCustomerLevel() {
        var row = $('#dg').datagrid('getSelected');
        if (!row) {
            Helper.Show('请选择需要删除的信息?');
            return false;
        }
        $.messager.confirm('提示信息', '您确认要删除吗?', function (r) {
            if (!r) { return false; }
            $.post("/BasicManage/DeleteCustomerLevel", { id: row.Id }, function (json) {
                Helper.Show(json.Msg);
                if (json.Success) {
                    $('#dg').datagrid('reload');
                }
            });
        });
    }

    function saveCustomerLevel() {
        $('#fm').form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: function (json) {
                var json = eval('(' + json + ')');
                Helper.Show(json.Msg);
                if (!json.Success) {
                    return false;
                }
                $('#fm').form('clear');
                $('#dlg').dialog('close');
                $('#dg').datagrid('reload');

            }
        });
    }
</script>



